<style>
    .buildDetail .popover {
        max-width: 400px !important;
    }
</style>

<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false;
    app.settings.asideDock = false;">
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row">
                <div class="col-sm-6 col-xs-12">
                    <h1 class="m-n font-thin h3 text-black"><span class="font-bold"><img
                            src="img/simpleicons/jenkins.svg" width="25" height="25"></span>Jenkins</h1>
                    <small class="text-muted">持续集成调度引擎</small>
                </div>
            </div>
        </div>
        <!-- / main header -->
        <div class="wrapper-md">
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}">
            </toaster-container>

            <!--标签页-->
            <div class="panel panel-default col-md-12" ng-controller="labelCtrl">
                <div class="panel-body">
                    <div class="form-group col-md-11">
                        <div class="col" ng-repeat="item in labelList">
                            <label class="btn btn-default" style="margin-left: 20px; background-color: {{item.color}}" ng-click="setLabel(item.labelName)">
                                <i class="fa fa-tag text-danger" ng-show="item.active"></i>
                                <b>{{item.labelName}}</b>
                            </label>
                        </div>
                    </div>

                    <div class="form-group col-md-1">
                        <button type="button" class="btn btn-xs pull-right"
                                style="background-color: #777; color: white;margin-top:5px;margin-left:5px;"
                                ng-click="editLabel()">
                            <span class="icon icon-settings"></span>
                        </button>

                        <button type="button" class="btn btn-xs pull-right"
                                style="background-color: #777; color: white;margin-top:5px;margin-left:5px;"
                                ng-click="addLabel()">
                            <span class="glyphicon glyphicon-plus"></span>
                        </button>
                    </div>
                </div>
            </div>

            <uib-accordion>
                <!--列表-->
                <div class="list-group col-md-3" ng-controller="ciAppCtrl">
                    <!--关键字搜索-->

                    <div uib-accordion-group class="panel-info" is-open=true>
                        <uib-accordion-heading>应用列表</uib-accordion-heading>
                        <form class="form-inline" role="form">
                            <div class="input-group">
                                <span class="input-group-addon">应用</span>
                                <input type="text" class="form-control" ng-model="queryName" placeholder="名称">
                            </div>
                            <button type="button" class="btn btn-info" ng-click="queryMyCiApp(queryName)"><span
                                    class="glyphicon glyphicon-search"></span>
                            </button>
                            <button type="button" class="btn btn-success" ng-click="addApp()"><span
                                    class="glyphicon glyphicon-plus"></span>
                            </button>
                        </form>
                        <!--<p style="color:#2ea8e5">{{workflowGroup.content}}</p>-->
                        <div ng-repeat="ciApp in ciAppList">
                            <hr/>
                            <!--{{ciApp.btn.background}}-->
                            <button type="button" class="btn btn-default"
                                    style="background-color: {{ciApp.btn.background}};box-shadow: 0 0 5px #ddd;padding: 10px;"
                                    uib-popover-html="ciApp.content"
                                    popover-trigger="'mouseenter'"
                                    ng-click="setCiApp(ciApp)">
                                <embed ng-if="ciApp.appType == 0" class="pull-left" style="margin-top:2px;"
                                       src="img/simpleicons/java.svg" width="15" height="15"
                                       type="image/svg+xml"
                                       pluginspage="img/simpleicons/"></embed>
                                <embed ng-if="ciApp.appType == 1" class="pull-left" style="margin-top:2px;"
                                       src="img/simpleicons/python.svg" width="15" height="15"
                                       type="image/svg+xml"
                                       pluginspage="img/simpleicons/"></embed>
                                <embed ng-if="ciApp.appType == 2" class="pull-left" style="margin-top:2px;"
                                       src="img/simpleicons/apple.svg" width="15" height="15"
                                       type="image/svg+xml"
                                       pluginspage="img/simpleicons/"></embed>
                                <embed ng-if="ciApp.appType == 3" class="pull-left" style="margin-top:2px;"
                                       src="img/simpleicons/android.svg" width="15" height="15"
                                       type="image/svg+xml"
                                       pluginspage="img/simpleicons/"></embed>
                                <embed ng-if="ciApp.appType == 4" class="pull-left" style="margin-top:4px;"
                                       src="img/simpleicons/test.svg" width="15" height="15"
                                       type="image/svg+xml"
                                       pluginspage="img/simpleicons/"></embed>
                                <b style="color: {{ciApp.btn.color}};margin-left: 5px;">{{ciApp.appName}}</b></span>
                            </button>

                            <button type="button" class="btn btn-xs pull-right"
                                    ng-show="ciApp.click && contains(authPoint, '/ci/app/del')"
                                    style="background-color: red; color: white;margin-top:5px;margin-left:5px;"
                                    ng-click="delApp(ciApp)">
                                <span class="glyphicon glyphicon-trash"></span>
                            </button>
                            <button type="button" class="btn btn-xs pull-right"
                                    ng-show="ciApp.click"
                                    style="background-color: #777; color: white;margin-top:5px;margin-left:5px;"
                                    ng-click="editUser(ciApp)">
                                <span class="icon icon-user"></span>
                            </button>
                            <button type="button" class="btn btn-xs pull-right"
                                    ng-show="ciApp.click"
                                    style="background-color: #777; color: white;margin-top:5px;"
                                    ng-click="editApp(ciApp)">
                                <span class="icon icon-settings"></span>
                            </button>
                            <b></b>
                        </div>
                    </div>

                </div>
            </uib-accordion>

            <uib-tabset class="list-group col-md-9">
                <div class="panel panel-default" ng-controller="ciJobCtrl">
                    <div class="panel-body">
                        <form name="form" class="form-inline">
                            <div class="input-group">
                                <span class="input-group-addon">应用名称</span>
                                <input type="text" class="form-control" ng-model="ciApp.appName" readonly>
                            </div>
                            <div class="input-group">
                                <span class="input-group-addon">项目名称</span>
                                <input type="text" class="form-control" ng-model="ciApp.projectName" readonly>
                            </div>
                            <button type="button" class="btn btn-success" ng-show="ciApp.projectName != ''"
                                    ng-click="addJob()"><span class="icon icon-puzzle"></span>新建任务
                            </button>

                            <button type="button" class="btn btn-success" ng-show="ciApp.projectName != ''"
                                    ng-click="queryAppJob()"><span
                                    class="glyphicon glyphicon-repeat"></span>刷新任务
                            </button>
                            <hr/>

                            <!--维护公告-->
                            <uib-accordion close-others="false" ng-if="false">
                                <div class="panel">
                                    <form class="form-horizontal col-md-12"
                                          style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                        <div ng-show="!mdEditing" ng-bind-html="md.preview"></div>

                                        <div ng-show="mdEditing" ui-ace="aceOption" ng-model="md.mdBody"
                                             class="ace_editor"></div>
                                    </form>
                                </div>
                            </uib-accordion>
                            <!--is-open=true-->
                            <!--任务列表-->
                            <uib-accordion close-others="false">
                                <div class="panel">
                                    <div uib-accordion-group class="panel-info"
                                         style="box-shadow: 0 0 5px #ddd;padding: 10px;" is-open=true>
                                        <uib-accordion-heading>任务列表

                                        </uib-accordion-heading>

                                        <div style="margin-top: 5px;">
                                            <table class="table table-striped">
                                                <thead>
                                                <tr>
                                                    <td class="col-md-3">持续集成任务名称</td>
                                                    <td>LastBuild</td>
                                                    <td class="col-md-1">环境</td>
                                                    <td class="col-md-1" ng-if="false">规范</td>
                                                    <td>分支</td>
                                                    <td>操作</td>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <tr ng-repeat="ciJob in ciJobList">
                                                    <td>
                                                        <b style="color: #286090" class="pull-left"
                                                           uib-popover-html="ciJob.content" popover-trigger="'mouseenter'">{{ciJob.jobName}}</b>
                                                    <td>
                                                        <div class="col-md-1" ng-repeat="bd in ciJob.buildDetails">
                                                                <span class="badge"
                                                                      style="background-color:{{bd.color}};color: white;"
                                                                      uib-popover-html="bd.info"
                                                                      popover-trigger="'mouseenter'">
                                                                    <span class="fa fa-spin fa-spinner"
                                                                          ng-show="bd.building"
                                                                          style="color: white"></span>{{bd.buildNumber}}</span>
                                                        </div>
                                                    </td>
                                                    </td>
                                                    <td>
                                                        <b style="color: {{ciJob.env.color}}">{{ciJob.env.name}}</b>
                                                    </td>
                                                    <td ng-if="false">
                                                        <span uib-popover-html="'启用GitFlow分支规范'"
                                                              popover-trigger="'mouseenter'"
                                                              ng-show="ciJob.ciAppVO.gitFlow"
                                                              class="icon icon-lock">
                                                        </span>
                                                        <span uib-popover-html="'自由模式'"
                                                              popover-trigger="'mouseenter'"
                                                              ng-show="!ciJob.ciAppVO.gitFlow"
                                                              class="icon icon-social-twitter">

                                                        </span>
                                                    </td>
                                                    <td>
                                                        <div ng-show="ciJob.branch != ''">
                                                            <i class="fa fa-code-fork"></i>
                                                            <b style="color: #777777">{{ciJob.branch}}</b>
                                                        </div>
                                                        <b ng-show="ciJob.branch == ''"
                                                           style="color: #777777">手动选择</b>
                                                    </td>
                                                    <td>

                                                        <button class="btn btn-xs"
                                                                style="margin-right: 5px; background-color: #2b669a; color: white;"
                                                                ng-click="buildJob(ciJob)"
                                                                uib-popover-html="'构建任务'"
                                                                popover-trigger="'mouseenter'">
                                                            <span ng-show="ciJob.ciAppVO.appType != 3"
                                                                  class="icon icon-control-play"></span>
                                                            <span ng-show="ciJob.ciAppVO.appType == 3"
                                                                  class="fa fa-android"></span>
                                                        </button>

                                                        <button class="btn btn-xs"
                                                                ng-show="ciJob.ciAppVO.appType == 0"
                                                                style="margin-right: 5px; background-color: #777; color: white;"
                                                                ng-click="deployJob(ciJob)"
                                                                uib-popover-html="'部署任务'"
                                                                popover-trigger="'mouseenter'">
                                                            <span class="icon icon-cloud-upload"></span>
                                                        </button>

                                                        <button class="btn btn-xs"
                                                                ng-show="ciJob.ciAppVO.appType == 3 && ciJob.deployJobName != '' "
                                                                style="margin-right: 5px; background-color: #777; color: white;"
                                                                ng-click="jiaguJob(ciJob)"
                                                                uib-popover-html="'加固任务'"
                                                                popover-trigger="'mouseenter'">
                                                            <span class="fa fa-empire"></span>
                                                        </button>

                                                        <button class="btn btn-xs"
                                                                style="margin-right: 5px; background-color: #777; color: white;"
                                                                ng-click="editJob(ciJob)"
                                                                uib-popover-html="'编辑持续集成任务'"
                                                                popover-trigger="'mouseenter'">
                                                            <span class="glyphicon glyphicon-edit"></span>
                                                        </button>

                                                        <button class="btn btn-xs"
                                                                style="margin-right: 5px; background-color: #777; color: white;"
                                                                ng-click="createJob(ciJob.id)"
                                                                uib-popover-html="'创建持续集成任务'"
                                                                popover-trigger="'mouseenter'">
                                                            <span class="glyphicon glyphicon-plus"></span>
                                                        </button>


                                                        <button class="btn btn-xs pull-right"
                                                                ng-if="contains(authPoint, '/ci/admin')"
                                                                style="margin-right: 5px; background-color: red; color: white;"
                                                                ng-click="delJob(ciJob.id)"
                                                                uib-popover-html="'删除持续集成应用任务'"
                                                                popover-trigger="'mouseenter'">
                                                            <span class="fa fa-spin fa-spinner"
                                                                  ng-show="btnTodoClick"></span>
                                                            <span class="glyphicon glyphicon-remove"></span>
                                                        </button>
                                                    </td>
                                                </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>

                                    <!--<div id="ciGraph"></div>-->
                                </div>
                            </uib-accordion>

                            <div class="col-md-6" id="deployInfo"
                                 style="min-width: 320px; max-width: 1200px;margin: 0 auto;box-shadow: 0 0 5px #ddd;padding: 10px;"></div>


                        </form>
                    </div>
                </div>

            </uib-tabset>

        </div>
    </div>
    <!-- / main -->
</div>

<script type="text/ng-template" id="ciAppModal">
    <div ng-include="'tpl/modal/ci/ci_app_modal.html'"></div>
</script>

<script type="text/ng-template" id="ciJobModal">
    <div ng-include="'tpl/modal/ci/ci_job_modal.html'"></div>
</script>

<script type="text/ng-template" id="ciBuildModal">
    <div ng-include="'tpl/modal/ci/ci_build_modal.html'"></div>
</script>

<script type="text/ng-template" id="ciBuildAndroidModal">
    <div ng-include="'tpl/modal/ci/ci_build_android_modal.html'"></div>
</script>

<script type="text/ng-template" id="ciBuildTestModal">
    <div ng-include="'tpl/modal/ci/ci_build_test_modal.html'"></div>
</script>

<script type="text/ng-template" id="ciDeployModal">
    <div ng-include="'tpl/modal/ci/ci_deploy_modal.html'"></div>
</script>

<script type="text/ng-template" id="ciJiaguModal">
    <div ng-include="'tpl/modal/ci/ci_jiagu_modal.html'"></div>
</script>

<script type="text/ng-template" id="ciAppUserModal">
    <div ng-include="'tpl/modal/ci/ci_app_user_modal.html'"></div>
</script>


<script type="text/ng-template" id="addLabelModal">
    <div ng-include="'tpl/modal/ci/add_label_modal.html'"></div>
</script>


<script type="text/ng-template" id="editLabelModal">
    <div ng-include="'tpl/modal/ci/edit_label_modal.html'"></div>
</script>